package cn.edu.nju.software.dao.intf;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import cn.edu.nju.software.bean.show.BookItemInOrder;
import cn.edu.nju.software.bean.show.OrderSearchListItem;
import cn.edu.nju.software.bean.storage.Order;

public interface OrderDao {
	
	public abstract List<OrderSearchListItem> getAllOrders() throws SQLException;
	
	/** This method searches for comments according to the provided criteria.
	 * 
	 * @param criteria
	 * @return
	 * @throws SQLException
	 */
	public abstract List<OrderSearchListItem> searchOrders(Map<Integer, Object> criteria)
			throws SQLException;

	public abstract Order getOrderById(int id) throws SQLException;
	
	/** This method submits a new order to the system.
	 * It returns the auto-generated order ID if the submit succeeds.
	 * @param order
	 * @param bookList
	 * @return int
	 * @throws SQLException
	 */
	public abstract int submitOrder(Order order, List<BookItemInOrder> bookList)
			throws SQLException;
	
	/** This method cancels the specified order by order ID.
	 * This method returns true if the order is cancelled.
	 * This method returns false if the order cannot be cancelled.
	 * This order object should contain any possible information you can
	 * provide at this moment.
	 * 
	 * @param orderID
	 * @return
	 * @throws SQLException
	 */
	public abstract boolean cancelOrder(int orderID) throws SQLException;
	
	/** This method dispatches the specified order by order ID.
	 * This method returns true if the order is dispatched.
	 * This method returns false if the order has been cancelled.
	 * This order object must contain the order ID and the dispatch time.
	 * 
	 * @param orderID
	 * @return
	 * @throws SQLException
	 */
	public abstract boolean dispatchOrder(Order order) throws SQLException;
	
	/** This method confirms the specified order by order ID.
	 * It updates the order status and the sales of the associated books.
	 * The order object must contain the order ID and the comfirmation time.
	 * 
	 * @param orderID
	 * @throws SQLException
	 */
	public abstract boolean confirmOrder(Order order) throws SQLException;
	
	public abstract boolean failOrder(int orderID) throws SQLException;
	
}
